package com.badibadi.activity;

import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.layout;
import com.badibadi.uniclubber.R.menu;

import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebMailActivity extends BaseActivity{

	//http://www.200.net/html/mail/index.htm
	private String url;
	private WebView webView;
	private MyRunnable r;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		goToTheTitle();
		setContentView(R.layout.activity_web_mail);
		

		 init();
	
	}

	private void init() {
		// TODO Auto-generated method stub
		this.findViewById(R.id.return_btn).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				WebMailActivity.this.finish();
			}
		});
		url=initEmail();
		//url="http://www.200.net/html/mail/index.htm";
		webView=(WebView)this.findViewById(R.id.webView1);
	//	EnterWebView(uri);
		 WebSettings webSettings = webView.getSettings();//获取webview配置
		 webSettings.setJavaScriptEnabled(true);
		 webView.loadUrl(url);
		
		 webView.setWebViewClient(new myWebViewClient());
		 this.findViewById(R.id.send).setVisibility(View.GONE);
	}
/**
 * 在这里初始化
 * @return
 */
	protected String initEmail()
	{
		return "www.soso.com";
	}
	
	
	
	 private class myWebViewClient extends WebViewClient { 
//		    @Override 
//		public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) { 
//		web.loadUrl(url); 
//		return true; 
//		 } 
		@Override
		public WebResourceResponse shouldInterceptRequest(WebView view,
				String url) {
			// TODO Auto-generated method stub
			 r=new MyRunnable();
		
			return super.shouldInterceptRequest(view, url);
		}
		 //webview中加载网页
		 @Override
		public boolean shouldOverrideUrlLoading(WebView view, String url) {
		// TODO Auto-generated method stub
			 r= new MyRunnable();

			 webView.loadUrl(url);
		return super.shouldOverrideUrlLoading(view, url);
		}
		 
	} 
	 
	 class MyRunnable implements Runnable{
		public void run() {
//			text.setText(url);
			
		}
	}
	 
//		@SuppressLint("NewApi")
//		public void android4Detail(){
//		if (Build.VERSION.SDK_INT >= 11) {
//		   StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
//		   StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
//		 }
//	}
}
